﻿/* 
 * Since 2008 - 2013
 */

package com.hh.bss.oa.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

import com.hh.bss.base.*;
import com.hh.bss.common.page.*;
import com.hh.bss.common.page.impl.*;
import com.hh.bss.oa.dao.*;
import com.hh.bss.oa.entity.*;
import com.hh.bss.oa.service.*;
import com.hh.bss.oa.vo.query.*;
import com.hh.bss.util.*;




@Service
@Transactional
public class OaMeetingRoomLogServiceImpl extends BaseBusinessService<OaMeetingRoomLog,java.lang.Integer>  implements OaMeetingRoomLogService<OaMeetingRoomLog,java.lang.Integer>{

	private OaMeetingRoomLogDao oaMeetingRoomLogDao;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写*/
	public void setOaMeetingRoomLogDaoImpl(OaMeetingRoomLogDao dao) {
		this.oaMeetingRoomLogDao = dao;
	}
	public EntityDao getEntityDao() {
		return this.oaMeetingRoomLogDao;
	}
	
	@Transactional(readOnly=true)
	public Page findPage(OaMeetingRoomLogQuery query) {
		return oaMeetingRoomLogDao.findPage(query);
	}
	public List findList(OaMeetingRoomLogQuery query) {
		return oaMeetingRoomLogDao.findList(query);
	}
	@Override
	public void addOaMeetingRoomLog(OaMeetingRoomTaking oaMeetingRoomTaking) {
		// TODO Auto-generated method stub
		//检查是否存在
		List values = new ArrayList();
		values.add(oaMeetingRoomTaking.getId());
		values.add(oaMeetingRoomTaking.getOrderDate());//一般是今天
		values.add(oaMeetingRoomTaking.getBeginDt());
		values.add(oaMeetingRoomTaking.getEndDt());
		List l=getEntityDao().getHibernateTemplate().find("from OaMeetingRoomLog t where t.taskId=? and t.meetingDate=? and t.beginDt=? and t.endDt=? ",values.toArray());
		//已经存在则不处理
		if (l!=null&&l.size()>0) return;
		//通过OaMeetingRoomTaking 来增加OaMeetingRoomLog
		OaMeetingRoomLog oaMeetingRoomLog=new OaMeetingRoomLog();
		oaMeetingRoomLog.setRoomId(oaMeetingRoomTaking.getRoomId());
		oaMeetingRoomLog.setTaskId(oaMeetingRoomTaking.getId());
		oaMeetingRoomLog.setMeetingDate(oaMeetingRoomTaking.getOrderDate());
		oaMeetingRoomLog.setBeginDt(oaMeetingRoomTaking.getBeginDt());
		oaMeetingRoomLog.setEndDt(oaMeetingRoomTaking.getEndDt());
		oaMeetingRoomLog.setStatus(oaMeetingRoomTaking.getStatus());
		oaMeetingRoomLog.setCreateDt(new Date());
		
		oaMeetingRoomLog.setTitle(oaMeetingRoomTaking.getTitle());
		oaMeetingRoomLog.setUseType(oaMeetingRoomTaking.getUseType());
		oaMeetingRoomLog.setOrderAccount(oaMeetingRoomTaking.getOrderAccount());
		oaMeetingRoomLog.setPerson(oaMeetingRoomTaking.getPerson());
		
		oaMeetingRoomLogDao.save(oaMeetingRoomLog);
	}
	
}
